// Package _5_two_point 27-remove-elemrny
// @Title _5_two_point
// @Description
// @Author  == 琳琳也叫王木木 ==  2021/9/28 18:44
// @Create  2021/9/28 18:44
package _5_two_point

import "fmt"

func Demo27() {
	//fmt.Print(removeElement([]int{3,2,2,3},3))
	//fmt.Print(removeElement([]int{0,1,2,2,3,0,4,2},2))
	//fmt.Print(removeElement([]int{2},3))
	fmt.Print(removeElement([]int{1}, 1))
}

func removeElement(nums []int, val int) int {
	left := 0
	for _, v := range nums { // v 即 nums[right]
		if v != val {
			nums[left] = v
			left++
		}
	}
	return left
}
